package com.xiu.travel.security.controller;

import com.xiu.travel.util.ServletUtils;
import com.xiu.travel.util.api.CommonResult;
import com.xiu.travel.security.service.UmsMemberService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@Tag(name = "登陆接口", description = "登陆接口")
@RequestMapping("admin/api")
@Slf4j
public class LoginOutController
{

    @Autowired
    private UmsMemberService umsMemberService;

//    /**
//     * 退出登陆
//     *
//     * @return r result
//     * @author qianl
//     */
//    @PostMapping("logout")
//    @Operation(summary= "退出登陆")
//    public CommonResult<String> logout()
//    {
//        return umsMemberService.loginOut();
//    }

    /**
     * 退出登陆
     *
     * @return r result
     * @author qianl
     */
    @PostMapping("loginOut")
    @Operation(summary = "退出登陆")
    public CommonResult<String> loginOut()
    {

        ServletUtils.getResponse()
                    .setHeader(
                            "Set-Cookie",
                            "token=" + "1" + "; Domain=.clubm.top; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:10 GMT; " +
                                    "Path=/");

        return umsMemberService.loginOut();
    }
}
